<h2><a href="<?=site_url('company/'.$company->company_name);?>"><?=$company->company_name;?></a> &ndash; <?=$job->job_title;?></h2> 

<div class="block tabs spaces">
	
	<div class="hd">
		
		<ul>
			<li><a class="active" href="">Updates</a></li>
			<li><a href="<?=site_url('company/'.$company->company_name.'/'.$job->job_title.'/milestones');?>">Milestones</a></li>
			<li><a href="<?=site_url('company/'.$company->company_name.'/'.$job->job_title.'/costs');?>">Costs</a></li>
			<?php if ($permissions->createinvoice):?><li><a href="<?=site_url('company/'.$company->company_name.'/'.$job->job_title.'/billing');?>">Billing</a></li><?php endif;?>
			<li><a href="<?=site_url('company/'.$company->company_name.'/'.$job->job_title.'/setup');?>">Job Setup</a></li>
		</ul>
		
		<div class="clear"></div>
		
	</div>
	
	<div class="bd">

		<p class="alert notice">
			<strong>Progress: </strong><?php if ($totaltime > 0 && $allocatedtime > 0) echo number_format(($totaltime / $allocatedtime )*100, 0).'%'; else echo '--';?> <?php if ($permissions->showtime):?>
			<strong>Allocated: </strong> <?=$allocatedtime;?>hrs 
			<strong>Spent: </strong> <?=$totaltime;?>hrs 
			<strong>Yours: </strong> <?=$usertime;?>hrs<?php endif;?>
		</p>

<?php if (strlen($updatelist)):?>
<ul class="theList">
	<?=$updatelist;?>
</ul>
<?php else:?>
<p>No updates have been made to this job yet.</p>
<?php endif;?>

</div></div></div></div></div>

<div id="sidebar" class="yui-b">
	
<div class="block">
	<div class="hd">
		<h3>Add an Update</h3>
	</div>
	<div class="bd">
		<div class="addupdate" id="add-update-form">

		<?=form_open_multipart('jobs/addUpdate/', array('class' => 'addupdate') );?>
		<input type="hidden" name="companyid" value="<?=$company->id;?>" />
		<input type="hidden" name="jobid" value="<?=$job->id;?>" />

		<fieldset>
			<p><label><input type="radio" name="updatefor" value="general" checked="checked" /> This Job</label></p>

			<?php if ($permissions->selectdepartmentonupdate && $departments):?>
				<p>
					<label><input type="radio" name="updatefor" value="department" /> A Department</label>
					<select class="text" name="department">
					<?php foreach($departments as $department):?>
						<option value="<?=$department->id;?>"><?=$department->centertitle;?></option>
					<?php endforeach;?>
					</select>
					<?php endif;?>
				</p>

			<?php if ($permissions->selecttaskonupdate && $hastasks):?>
				<p>
					<label><input type="radio" name="updatefor" value="task" /> A Task</label>
					<select class="text" name="task">
					<?php if ($jobtasks):?>
						<?php foreach($jobtasks as $task):?>
						<option value="<?=$task->id;?>"><?=$task->activity_title;?></option>
						<?php endforeach;?>
					<?php endif;?>
					<?php foreach($departments as $department):?>
						<?php if ($department->tasks):?>
						<optgroup label="<?=$department->centertitle;?>">
						<?php foreach($department->tasks as $task):?>
							<option value="<?=$task->id;?>"><?=$task->activity_title;?></option>
						<?php endforeach;?>
						</optgroup>
					<?php endif;?>
					<?php endforeach;?>
				</select>
				</p>
			<?php endif;?>
		</fieldset>

		<fieldset>
			<p>
				<label>Update</label>
				<textarea class="text" name="notes" rows="10"></textarea>
			</p>
		</fieldset>

		<fieldset class="dateTime">
			<p>
			<label class="date">Date</label>
			<input class="text" type="text" name="dateapplicable" id="dateapplicable" value="<?=date('d/m/Y');?>" class="datepicker" />
			<?php if ($permissions->specifyhours):?>	
			<p>
				<label for="hoursworked" class="hours">Hours Worked</label><br />
				<input type="text" name="hoursworked" id="hoursworked" /> h
				<input type="text" name="minsworked" id="minsworked" /> m
			</p>
			<?php endif;?>

			<?php if ($permissions->specifybillable):?>
				<p><label><input type="checkbox" name="notbillable" id="notbillable" class="checkbox" value="1" /> Not Billable?</label></p>
			<?php endif;?>
		</fieldset>
		
		<fieldset>
			<?php if ($permissions->makepublicupdates):?>
			<p><label><input type="checkbox" name="public" id="public" class="checkbox" value="1" /> Make this update public?</label></p>
			<?php endif;?>

			<?php if (!$permissions->makepublicupdates && $permissions->forcepublicupdates):?>
			<input type="hidden" name="public" value="1" />
			<?php endif;?>
		</fieldset>

		<fieldset class="fileupload">
			<p><label for="fileupload">Attach Files</label>
			<input class="file" type="file" name="fileupload" class="multiupload" />
			<span class="info">Include files of type <strong>jpg</strong>, <strong>png</strong>, <strong>pdf</strong>, <strong>xls</strong> or <strong>doc</strong> upto <strong>10 Megabytes</strong> in your update.</span></p>
		</fieldset>

		<fieldset>
			<p><input class="submit" type="submit" name="submit" value="Add Update" /></p>
		</fieldset>
<?=form_close();?>

</div>
</div></div>

<?php if ($jobfiles):?>
	<div class="block">
		<div class="hd">
			<h3>Associated Files</h3>
		</div>
		<div class="bd">

			<?php if ($jobfiles):?>
			<?php foreach($jobfiles as $file):?>
			<div class="afile clearfix <?=url_title($file->file_type);?>">
				<?php if ( in_array($file->file_type, array('image/gif', 'image/jpeg', 'image/png', 'application/pdf') ) ):?>
				<img src="<?= resizedImageURL($file->file_path.$file->file_name, 50, 50, true, 'height')  ;?>" style="border: 1px solid #ccc; margin-right: 5px; float: left" />
				<?php endif; ?>
				<strong><a href="<?=site_url('files/download/'.$file->id);?>" class="<?php /* if ($permissions->editfiles):?>edit_textinput<?php endif; */ ?>" id="<?=$file->id;?>|files|title"><?=substr($file->title, 0, 25);?></a></strong>
				<?php if ($permissions->editfiles):?><p><?php if ($file->public):?>Public <small>(<a href="<?=site_url('files/makePrivate/'.$file->id);?>">make private</a></small><?php else:?>Private <small>(<a href="<?=site_url('files/makePublic/'.$file->id);?>">make public</a><?php endif;?>)</p><?php endif;?>
			</div>
			<?php endforeach;?>
		<?php endif;?>
		</div>
	</div>
<?php endif;?>